Skip to content

feat: add verified SecRandom integration SDK channel - #357

Closed
lzy98276 wants to merge 26 commits into
masterfrom
codex/integration-sdk-auth
Closed

lzy98276 wants to merge 26 commits into
masterfrom
codex/integration-sdk-auth

Conversation

@lzy98276

Copy link
Copy Markdown
Member

What changed

Adds a separately published official integration SDK and the SecRandom host channel for signed, user-approved local notifications.

The SDK provides roster and history persistence, random/fair draw APIs, signed discovery manifests, notification IPC, and linkage leases. Orchestrated draw is deliberately excluded. SecRandom discovers only official SDK clients, verifies the ECDSA P-256 publisher proof plus the loaded assembly hash and IPC peer PID, asks before persisting a channel, forwards committed results, supports channel removal, and hides/restores floating windows through linkage leases.

Verification

  • SDK Release build and 5 tests pass
  • GitHub Actions Build SDK passes: https://github.com/SECTL/SecRandom-Integration-SDK/actions/runs/44908244123
  • SecRandom desktop Release build passes with the public trust key injected
  • Core tests run: 1852 passed, 11 existing baseline failures remain outside this change
  • Full solution build is environment-blocked only by the missing Android SDK on this machine

Trust configuration

The public ECDSA key is injected through SECRANDOM_INTEGRATION_PUBLIC_KEY_SPKI_BASE64; the private signing key remains only in the SDK repository Actions Secret and the ignored local .env.

- 云备份:删除 CloudBackupService/CloudAutomaticBackupService/SectlCloudStorageClient/CloudBackupPackage 及备份页云 tab、云配置项与相关本地化;ArchiveKind.CloudBackup 仅保留为旧值,旧云包导入直接拒绝
- 证明链:删除 DrawProof.Chain/DrawProofChain、ProofChainStore、ProofIntegrityVerifier 与验证页链校验入口;证明文件保留为普通 OfflineReproducible 文档,服务端回执计算从未包含链字段,旧回执继续有效
- 配置防篡改:删除 SettingsIntegrityService/RecoveryService/CommandGate、App 启动闸门与 IPC/URL 分支、SecuritySettingsConfig 三个开关及安全页设置项与本地化;凭据 FormatVersion/AAD 未动
- 同步改写根、SecRandom、SecRandom.Core、SettingsPages 四份 AGENTS.md

涉及删除的测试:ProofChainTests、SettingsIntegrity*Tests、CloudBackup*Tests、SectlCloudStorageClientTests;DataArchiveServiceTests 增加旧云包拒绝用例
- UpdateSource 增加 Auto/Sectl,Auto 由 UpdateSourceResolver 并行探测后按延迟排序
- 设置页新增更新来源行,选择持久化到 UpdateSettingsConfig
- 桌面与手机端按所选源获取 tag、清单与安装包,Ed25519/SHA-512/tag/channel 校验不变
- 官方源使用 /api/software/latest-tag 与不计数 /api/software/update-file
- 更新来源行重新纳入设置搜索
- 平台层新增一次性屏幕亮度采样(IScreenLuminanceSampler):Windows 走 GDI BitBlt + 亮度直方图,其它平台回退 Unsupported,绝不当作截屏流
- Core 新增 AdaptiveTheme/AdaptiveBackdropResolver,按亮度分位决定白/黑前景与 scrim 不透明度,文字对比度不低于 WCAG 4.5:1
- 通知窗显示前并行建窗与采样:60ms 超时,窗口以 Opacity=0 占位后 90ms 淡入,采样失败回退应用主题
- 新增开关 NotificationSettings.Default.AdaptiveForeground(默认开启;低配模式下置灰显示为关且不改写用户偏好,采样同样跳过)
- 全屏通知的动画样式与背景模糊在低配下置灰并显示实际生效值,与开关同规则
- 内置通知浮窗的窗口几何收归独立设置页,渠道页不再重复同一组控件
数据根不再等同于程序目录下的 data/,桌面端改为按优先级解析:
--data-root > SECRANDOM_DATA_ROOT > 锚点 data-root.json > 旧位置认领 > 模式默认。

- 安装版默认使用 per-user 标准位置(Windows %LOCALAPPDATA%\SecRandom\data,
  macOS ~/Library/Application Support/SecRandom/data,Linux
  ${XDG_CONFIG_HOME:-~/.config}/secrandom/data),不再把数据写进安装目录;
  便携版继续使用 <包根>/data,锚点写在数据根之外。
- 旧位置(安装目录内 data/、app-*/data)会被识别认领:便携版把落在 payload 里的
  数据迁回包根,安装版只在设置页提示,不自动搬动。
- 新增两阶段迁移事务:设置页校验并写 data-root-journal.json,带
  --data-root-migration <id> 重启,迁移窗口在同卷 staging 复制、校验(小文件
  SHA-256,大媒体长度+修改时间)、改写根绝对路径后 rename 提交;锚点写入是唯一
  提交点,失败时目标回退为 staging、源保持完整,旧目录保留为 .migrated-<时间戳>。
- 新增设置页 settings.general.storage:显示当前根/来源/锚点、三种模式切换、
  目录选择、迁移预检与授权(复用 RestartApplication 验证门)、旧位置清单。
- 持久化图片路径改为根相对(DataPathReference.ToStored/Resolve),迁移时
  DataRootPathRewriter 改写 list/**/*.json 的 ImagePath 与证明队列的 path。
- 便携更新部署前拒绝「数据根位于被替换 payload 内」的情况并提示迁移。
- 新增 22 例数据目录测试(解析优先级、锚点读写、路径相对化、改写、迁移引擎)。
- 文字样式可自定义内容:中文界面一个字,其它语言最多四个字符,存储按四个字符兜底并过滤 emoji
- 图标样式可选内置 Fluent 图标或导入图片,图片与自定义按钮图标同目录并由 Prune 一并保留
- 箭头样式改用 ChevronLeft/ChevronRight 图标,不再使用字符
- 设置页按所选样式显示手柄文字/手柄图标条件卡片,新增三语文案
- 三个外观字段在集控中保持只读,避免远端改写本机外观
`IPlatformServiceRoot` 新增 `ScreenLuminance` 后,`MobilePlatformServiceRoot` 忘记实现,导致全解决方案构建报 CS0535。移动端没有桌面可采样,按平台约定返回 `UnsupportedScreenLuminanceSampler.Instance`。
`NotificationSettingsConfig` 引用 `NotificationCountdownPalette`(倒计时描边色标),但该类型一直未被跟踪,导致全解决方案构建报 CS0103。文件自包含,只依赖 Avalonia.Media。
保留 v1 全部 URL/IPC 路由;新增 37 个 v2 方法、独立事件管道、自动化总开关、页面注册表解析、审计日志与 v1/v2 测试。URL 激活禁止触发抽取/重启/退出。
- 当前目录、位置来源、位置记录文件合并为一张「数据目录」卡,默认展开
- 位置类型改用普通设置卡,下拉框放在卡内右侧
- 按设置页文案规范去掉说明与提示里的句号(中文、英文、日文三语)
- 新增随机数抽取设置页,提供点名/抽奖默认数字范围与重置行为
- 将“不使用名单”入口文案改为“随机数”,哨兵值不变
- 数字抽取提交成功后写入 data/history/random-number/stats.json,概览页展示累计与最近记录
- 重置默认只清临时剩余;可选同时清除随机数统计,名单历史始终保留
- 补配置夹取、统计服务与重置语义测试
- 删除按钮上方的自定义文字横幅、设置卡与 EnableFloatingWindowText/FloatingWindowText/FloatingWindowTextFontSize 配置
- 收纳手柄文字输入框改为 120 宽并去掉占位提示,留空仍回退到默认的“抽”
- 内置图标选择对话框的“图标”表头改为不换行(NoWrap TextBlock,图标列 64→72)
- 同步三语资源、设计器属性、集控标签与 AGENTS.md 说明
- 迁移操作拆成独立设置卡(标题即按钮名),不再裸放一个按钮
- 自定义数据位置卡仅在“自定义位置”模式下显示,路径输入与浏览放卡右侧
- 切换位置类型时目标路径跟随该类型的默认目录,切回自定义时恢复用户选过的目录
- 新增 S_Migrate_D 文案(中/英/日)
- 新增 DrawMode.Orchestrated 与 builtin.orchestrated 抽取方式:顺序在抽取前排定,按队列取人
- 编排名单是独立实体:排斥全局,权重/延后/顺序/必中按轮稀疏保存,最多 10 轮
- 编排设置页为总览 + 五个隐藏子页(exclude/weight/defer/order/guarantee),共用规则页基类
- 抽取引擎抽出 DrawModeSelection/DrawRepeatPolicy,公平模式增加 UniformFirst/RandomFirst
- 抽取审计补充 DrawModeToken/HistoryScope/ExcludedCandidateCount 等上下文字段
- 新增 DrawMode.Orchestrated 与 builtin.orchestrated 抽取方式:顺序在抽取前排定,按队列取人
- 编排名单是独立实体:排斥全局,权重/延后/顺序/必中按轮稀疏保存,最多 10 轮
- 编排设置页为总览 + 五个隐藏子页(exclude/weight/defer/order/guarantee),共用规则页基类
- 抽取引擎抽出 DrawModeSelection/DrawRepeatPolicy,公平模式增加 UniformFirst/RandomFirst
- 抽取审计补充 DrawModeToken/HistoryScope/ExcludedCandidateCount 等上下文字段
替换旧节点令牌控制面,增加账号接入、roster.list 与移动端账号控制台。
增加长按滑轨、网格结果、浮窗让位还原与按卡片透明度适配通知前景色。
增加连续倒计时圆环、渐变/单色调色板与兼容旧值的九宫格窗口位置。
允许删除最后名单,按当前历史组过滤移动记录,并提供数字编号删除后的前移预览。
覆盖课间限制验证、USB 绑定展示、数据根保护、文本库提示、随机数统计与自动化 IPC。
集中提交跨特性 App 注册、浮窗协调与同步更新后的 AGENTS 规则。
移除旧 v3.2.0 目录并新增 v3.2.0-beta.1 发布说明。
停机期间安全解析服务失败时返回空,并补充抽奖通道证明上下文与联动验证说明。
@lzy98276
lzy98276 requested a review from lrs2187 as a code owner November 21, 2026 13:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T13:48:40.165551Z bdcd4db PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chained.ProofId, chained.Mode, chained.Chain?.Index, path);
return new DrawProofExportResult(path, chained);
"已导出抽取证明:ProofId={ProofId},模式={Mode},路径={Path}。",
proof.ProofId, proof.Mode, path);

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdcd4db536

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread SecRandom/App.axaml.cs
{
foreach (var window in FloatingWindows())
{
if (!window.IsVisible)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep SDK linkage suppression active across course hides

If an SDK lease is acquired while a course break has already hidden a floating window, this skips the window without adding it to _integrationSuppressedWindows; when the break ends, ApplyCourseLinkageVisibility restores it even though the SDK lease is still active. Treat SDK and course hiding as overlapping suppression state so the window stays hidden until both restrictions end.

AGENTS.md reference: SecRandom/AGENTS.md:L88-L88

Useful? React with 👍 / 👎.

{
var item = jsonArray[index];
if (TryReadString(item, out var text) &&
RewriteValue(text, oldRoot, newRoot) is var rewritten &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Rewrite only known path-reference fields

When a list/**/*.json file contains an array-valued AttachedObjects or plugin setting, this branch rewrites every string element that looks like an absolute path under the old root, although only ImagePath is a known path field there. Those values are arbitrary plugin data and may not be resolved against the new root, so moving data can silently corrupt them; leave array strings alone unless their schema marks them as path references.

AGENTS.md reference: SecRandom.Core/AGENTS.md:L73-L73

Useful? React with 👍 / 👎.

Comment on lines +595 to +596
if (!drawing)
return await OnUiAsync(() => Task.FromResult(BuildDrawResult(target))).ConfigureAwait(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match draw.await to the advertised request contract

When a client awaits a specific roundId, this returns the cached result as soon as the default roll-call channel is idle; the registry never reads roundId, and it reads timeout_ms rather than the catalog's timeoutMs. A caller awaiting an active lottery or quick draw can therefore receive an unrelated stale result instead of waiting for the requested draw. SecRandom.Core/Services/Ipc/AutomationCommandRegistry.csL595-L596

Useful? React with 👍 / 👎.

protocol = AutomationCommandCatalog.ProtocolVersion,
maxSubscribers = AutomationEventServer.MaxSubscribers
}),
"events.unsubscribe" => Task.FromResult<object?>(new { unsubscribed = true }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make events.unsubscribe actually stop the subscription

Calling the advertised events.unsubscribe RPC only returns unsubscribed: true; the event subscriber runs on a separate long-lived pipe, and this handler has no reference to it or signal to stop it. The client therefore remains subscribed and consumes one of the 16 slots until it closes that pipe, despite receiving a successful unsubscribe response.

Useful? React with 👍 / 👎.

PipeTransmissionMode.Byte,
PipeOptions.Asynchronous | PipeOptions.CurrentUserOnly);

await server.WaitForConnectionAsync(cancellationToken).ConfigureAwait(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate event subscriptions with the automation IPC setting

When AutomationIpcEnabled is switched off, AutomationIpcServer rejects command requests, but this independent event server still accepts subscribers and leaves existing subscriptions active. An in-flight operation can consequently publish an event after the user disabled structured IPC; apply the same setting to event subscriptions and active clients.

Useful? React with 👍 / 👎.

Comment on lines +213 to +215
{
if (Directory.Exists(target))
return FinishCommit(target, source, progress);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the target before completing an interrupted migration

If the user chose a pre-existing empty target directory and the process is interrupted after saving the Committing state but before Commit removes that directory and moves the staged copy, the next launch takes this branch just because the target exists and calls FinishCommit on the empty directory. It then writes the anchor and archives the populated source, so the app adopts an empty data root; verify that the target contains the committed copy before finishing the journal.

AGENTS.md reference: SecRandom.Core/AGENTS.md:L73-L73

Useful? React with 👍 / 👎.

@lzy98276

Copy link
Copy Markdown
Member Author

Superseded by #358, which is rebased on the current master baseline and contains only the integration SDK changes.

@lzy98276 lzy98276 closed this Nov 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants